package com.neusoft.${bigModuleName}.controller.${tableName};

import com.neusoft.${bigModuleName!}.remote.dto.${tableName}.${TableName}Dto;
import com.neusoft.${bigModuleName!}.remote.service.${tableName}.I${TableName}Service;
import com.neusoft.${bigModuleName!}.vo.${tableName}.${TableName}Vo;
import com.neusoft.${bigModuleName!}.vo.${tableName}.${TableName}PageRequestVo;
import com.panshicloud.common.base.PageDto;
import com.panshicloud.common.base.request.IdsRequestVo;
import com.panshicloud.common.base.response.GenericResponseVo;
import com.panshicloud.common.helper.ConvertHelper;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ${tableComment!}
 * @author ${author}
 * @since ${date}
 */
@RestController
@RequestMapping("${bigModuleName}/${tableName}")
public class ${TableName}Controller{
    @Resource
    private I${TableName}Service service;

    /**
     * 新增保存
     */
    @PostMapping("/getById")
    public GenericResponseVo getById(@RequestBody ${TableName}Vo vo)
    {
        return new GenericResponseVo(service.doGetById(vo.getId()));
    }
    @PostMapping("/upsert")
    public GenericResponseVo addSave(@RequestBody ${TableName}Vo vo)
    {
        ${TableName}Dto dto = ConvertHelper.tToV(vo, ${TableName}Dto.class);
        return new GenericResponseVo(service.doUpsert(dto));
    }
    /**
     * 查询分页
     **/
    @PostMapping("/page")
    public GenericResponseVo page(@RequestBody ${TableName}PageRequestVo vo)
    {
        ${TableName}Dto dto = new ${TableName}Dto();
        dto.setJobName(vo.getJobName());
        PageDto<${TableName}Dto> pageDto = service.doPage(vo.getPageNumber(),vo.getPageSize(),dto);
        return new GenericResponseVo(pageDto);
    }
    /**
     * 查询列表
     **/
    @PostMapping("/list")
    public GenericResponseVo list(${TableName}Vo vo)
    {
        List<${TableName}Dto> dtos = service.doList();
        return new GenericResponseVo(dtos);
    }
    /**
     * 删除
     */
    @PostMapping( "/remove")
    public GenericResponseVo remove(@RequestBody IdsRequestVo vo)
    {
        return new GenericResponseVo(service.doRemove(vo.getIds()));
    }


}

